<template>
    <div class="default-main ba-table-box">
        <el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />

        <!-- 表格顶部菜单 -->
        <TableHeader
            :buttons="['refresh', 'add', 'delete', 'comSearch', 'quickSearch', 'columnDisplay']"
            :quick-search-placeholder="t('quick Search Placeholder', { fields: t('tz.quick Search Fields') })"
        />

        <!-- 表格 -->
        <!-- 要使用`el-table`组件原有的属性，直接加在Table标签上即可 -->
        <Table ref="tableRef" />

        <!-- 表单 -->
        <PopupTabs />
    </div>
</template>

<script setup lang="ts">
import { ref, provide, onMounted } from 'vue'
import baTableClass from '/@/utils/baTable'
import { tz } from '/@/api/controllerUrls'
import { defaultOptButtons } from '/@/components/table'
import { baTableApi } from '/@/api/common'
import { useI18n } from 'vue-i18n'
import PopupTabs from './PopupTabs.vue'
import Table from '/@/components/table/index.vue'
import TableHeader from '/@/components/table/header/index.vue'

const { t } = useI18n()
const tableRef = ref()
const optButtons = defaultOptButtons(["edit","delete"])
const baTable = new baTableClass(
    new baTableApi(tz),
    {
        pk: 'TZID',
        column: [
            { type: 'selection', align: 'center', operator: false },
            { label: t('tz.TZID'), prop: 'TZID', align: 'center' },
            { label: t('tz.YBH'), prop: 'YBH', align: 'center' },
            { label: t('tz.SENDER'), prop: 'SENDER', align: 'center' },
            { label: t('tz.GOODSC'), prop: 'GOODSC', align: 'center' },
            { label: t('tz.CONTRACTNO'), prop: 'CONTRACTNO', align: 'center' },
            // 箱号
            { label: t('tz.PORTLOADAGENT'), prop: 'PORTLOADAGENT', align: 'center' },
            //装货地
            //装货时间
            { label: t('tz.SHIPPERSERVICENO'), prop: 'SHIPPERSERVICENO', align: 'center' },
            //送货时间
            { label: t('tz.NEXTVESSEL'), prop: 'NEXTVESSEL', align: 'center' },
            // 回场时间
            //箱型
            //车队
            { label: t('tz.TRANSITEM'), prop: 'TRANSITEM', align: 'center' },
            { label: t('tz.FREIGHTITEM'), prop: 'FREIGHTITEM', align: 'center' },
            { label: t('tz.VESSEL'), prop: 'VESSEL', align: 'center' },
            // { label: t('tz.BOOKINGNO'), prop: 'BOOKINGNO', align: 'center' },
            // { label: t('tz.PORT'), prop: 'PORT', align: 'center' },
            // { label: t('tz.PORTLOAD'), prop: 'PORTLOAD', align: 'center' },
            // { label: t('tz.PORTLOADDOCK'), prop: 'PORTLOADDOCK', align: 'center' },
            // { label: t('tz.PORTVIA'), prop: 'PORTVIA', align: 'center' },
            // { label: t('tz.PORTDIS'), prop: 'PORTDIS', align: 'center' },
            // { label: t('tz.PORTDISDOCK'), prop: 'PORTDISDOCK', align: 'center' },
            // { label: t('tz.GETCNTRAREA'), prop: 'GETCNTRAREA', align: 'center' },
            // { label: t('tz.PUTCNTRAREA'), prop: 'PUTCNTRAREA', align: 'center' },
            // { label: t('tz.FLOW'), prop: 'FLOW', align: 'center' },
            // { label: t('tz.INOUT'), prop: 'INOUT', align: 'center' },
            // { label: t('tz.DIRECTION'), prop: 'DIRECTION', align: 'center' },
            // { label: t('tz.VOY'), prop: 'VOY', align: 'center' },
            // { label: t('tz.ETD'), prop: 'ETD', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.SHIPOWNER'), prop: 'SHIPOWNER', align: 'center' },
            // { label: t('tz.CNTRCORP'), prop: 'CNTRCORP', align: 'center' },
            // { label: t('tz.CHANGEVESSEL'), prop: 'CHANGEVESSEL', align: 'center' },
            // { label: t('tz.BATCHABLE'), prop: 'BATCHABLE', align: 'center' },
            // { label: t('tz.ATCUSTOMS'), prop: 'ATCUSTOMS', align: 'center' },
            // { label: t('tz.OTHERCONVEYANCE'), prop: 'OTHERCONVEYANCE', align: 'center' },
            // { label: t('tz.WAREHOUSENO'), prop: 'WAREHOUSENO', align: 'center' },
            // { label: t('tz.NEXTVOY'), prop: 'NEXTVOY', align: 'center' },
            // { label: t('tz.NEXTBLNO'), prop: 'NEXTBLNO', align: 'center' },
            // { label: t('tz.NEXTETD'), prop: 'NEXTETD', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.NEXTETA'), prop: 'NEXTETA', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.NEXTPORTDIS'), prop: 'NEXTPORTDIS', align: 'center' },
            // { label: t('tz.INTEGRATE'), prop: 'INTEGRATE', align: 'center' },
            // { label: t('tz.PORTDISAGENT'), prop: 'PORTDISAGENT', align: 'center' },
            // { label: t('tz.LOADBILLTYPE'), prop: 'LOADBILLTYPE', align: 'center' },
            // { label: t('tz.CUSNO'), prop: 'CUSNO', align: 'center' },
            // { label: t('tz.PACKSUM'), prop: 'PACKSUM', align: 'center', operator: 'RANGE' },
            // { label: t('tz.PACKAGE'), prop: 'PACKAGE', align: 'center' },
            // { label: t('tz.GWET'), prop: 'GWET', align: 'center', operator: 'RANGE' },
            // { label: t('tz.GOODSSIZE'), prop: 'GOODSSIZE', align: 'center', operator: 'RANGE' },
            // { label: t('tz.ISDANGER'), prop: 'ISDANGER', align: 'center' },
            // { label: t('tz.CONTAINERTYPE'), prop: 'CONTAINERTYPE', align: 'center' },
            // { label: t('tz.MIXNO'), prop: 'MIXNO', align: 'center' },
            // { label: t('tz.RELEASETYPE'), prop: 'RELEASETYPE', align: 'center' },
            // { label: t('tz.SALER'), prop: 'SALER', align: 'center' },
            // { label: t('tz.SALERDEPT'), prop: 'SALERDEPT', align: 'center' },
            // { label: t('tz.OCEANTRANSITEM'), prop: 'OCEANTRANSITEM', align: 'center' },
            // { label: t('tz.OTHERFREIGHTITEM'), prop: 'OTHERFREIGHTITEM', align: 'center' },
            // { label: t('tz.SETTLEMENT'), prop: 'SETTLEMENT', align: 'center' },
            // { label: t('tz.GOODSSUM'), prop: 'GOODSSUM', align: 'center', operator: 'RANGE' },
            // { label: t('tz.IPTYPE'), prop: 'IPTYPE', align: 'center' },
            // { label: t('tz.IPRATE'), prop: 'IPRATE', align: 'center', operator: 'RANGE' },
            // { label: t('tz.RECEIVER'), prop: 'RECEIVER', align: 'center' },
            // { label: t('tz.STORAGEFROM'), prop: 'STORAGEFROM', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.STORAGETO'), prop: 'STORAGETO', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.CHECKED'), prop: 'CHECKED', align: 'center' },
            // { label: t('tz.BIZSTATUS'), prop: 'BIZSTATUS', align: 'center', render: 'tag', replaceValue: { 1: t('tz.BIZSTATUS 1') } },
            // { label: t('tz.CUSACCEPT'), prop: 'CUSACCEPT', align: 'center' },
            // { label: t('tz.PAYDOWN'), prop: 'PAYDOWN', align: 'center' },
            // { label: t('tz.INKEEP'), prop: 'INKEEP', align: 'center' },
            // { label: t('tz.ELECBOOKING'), prop: 'ELECBOOKING', align: 'center' },
            // { label: t('tz.ELECORDERID'), prop: 'ELECORDERID', align: 'center' },
            // { label: t('tz.OP'), prop: 'OP', align: 'center' },
            // { label: t('tz.OPDEPT'), prop: 'OPDEPT', align: 'center' },
            // { label: t('tz.OPTIME'), prop: 'OPTIME', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.OVERSTATUS'), prop: 'OVERSTATUS', align: 'center', render: 'tag', replaceValue: { 1: t('tz.OVERSTATUS 1') } },
            // { label: t('tz.OVEROP'), prop: 'OVEROP', align: 'center' },
            // { label: t('tz.OVERTIME'), prop: 'OVERTIME', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.MANIFESTREMARK'), prop: 'MANIFESTREMARK', align: 'center' },
            // { label: t('tz.BIZDEPTREMARK'), prop: 'BIZDEPTREMARK', align: 'center' },
            // { label: t('tz.REMARK'), prop: 'REMARK', align: 'center' },
            // { label: t('tz.HBL'), prop: 'HBL', align: 'center' },
            // { label: t('tz.TZCIQNO'), prop: 'TZCIQNO', align: 'center' },
            // { label: t('tz.RECEIVEOBLDATE'), prop: 'RECEIVEOBLDATE', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.DECLAREDATE'), prop: 'DECLAREDATE', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.PASSDATE'), prop: 'PASSDATE', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.LOADDATE'), prop: 'LOADDATE', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.CHANGEBLDATE'), prop: 'CHANGEBLDATE', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.CHANGEREQUIRED'), prop: 'CHANGEREQUIRED', align: 'center' },
            // { label: t('tz.CIQNAME'), prop: 'CIQNAME', align: 'center' },
            // { label: t('tz.FCLCONTAINERNO'), prop: 'FCLCONTAINERNO', align: 'center' },
            // { label: t('tz.CIQCHECK'), prop: 'CIQCHECK', align: 'center' },
            // { label: t('tz.CLEAN'), prop: 'CLEAN', align: 'center' },
            // { label: t('tz.PROPAGATION'), prop: 'PROPAGATION', align: 'center' },
            // { label: t('tz.APPLYCORP'), prop: 'APPLYCORP', align: 'center' },
            // { label: t('tz.PHONE'), prop: 'PHONE', align: 'center' },
            // { label: t('tz.FINALDEST'), prop: 'FINALDEST', align: 'center' },
            // { label: t('tz.CARGODIRECTION'), prop: 'CARGODIRECTION', align: 'center' },
            // { label: t('tz.OTHERBL'), prop: 'OTHERBL', align: 'center' },
            // { label: t('tz.INCOTERM'), prop: 'INCOTERM', align: 'center' },
            // { label: t('tz.INCOPLACE'), prop: 'INCOPLACE', align: 'center' },
            // { label: t('tz.DECLMODE'), prop: 'DECLMODE', align: 'center' },
            // { label: t('tz.MARK'), prop: 'MARK', align: 'center' },
            // { label: t('tz.FLAG1'), prop: 'FLAG1', align: 'center' },
            // { label: t('tz.FLAG2'), prop: 'FLAG2', align: 'center' },
            // { label: t('tz.FLAG3'), prop: 'FLAG3', align: 'center' },
            // { label: t('tz.FLAG4'), prop: 'FLAG4', align: 'center' },
            // { label: t('tz.FLAG5'), prop: 'FLAG5', align: 'center' },
            // { label: t('tz.FLAG6'), prop: 'FLAG6', align: 'center' },
            // { label: t('tz.FLAG7'), prop: 'FLAG7', align: 'center' },
            // { label: t('tz.FLAG8'), prop: 'FLAG8', align: 'center' },
            // { label: t('tz.FLAG9'), prop: 'FLAG9', align: 'center' },
            // { label: t('tz.FLAG10'), prop: 'FLAG10', align: 'center' },
            // { label: t('tz.ETA'), prop: 'ETA', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.METERAGE'), prop: 'METERAGE', align: 'center', operator: 'RANGE' },
            // { label: t('tz.AIRPLACE'), prop: 'AIRPLACE', align: 'center' },
            // { label: t('tz.AGENT'), prop: 'AGENT', align: 'center' },
            // { label: t('tz.YS'), prop: 'YS', align: 'center', operator: 'RANGE' },
            // { label: t('tz.YF'), prop: 'YF', align: 'center', operator: 'RANGE' },
            // { label: t('tz.YJT'), prop: 'YJT', align: 'center', operator: 'RANGE' },
            // { label: t('tz.TXDATE'), prop: 'TXDATE', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.ZHDATE'), prop: 'ZHDATE', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.SHDATE'), prop: 'SHDATE', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.DDDATE'), prop: 'DDDATE', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('tz.JOBNO'), prop: 'JOBNO', align: 'center' },
            // { label: t('tz.CC'), prop: 'CC', align: 'center' },
            // { label: t('tz.REMARK1'), prop: 'REMARK1', align: 'center' },
            // { label: t('tz.REMARK2'), prop: 'REMARK2', align: 'center' },
            // { label: t('tz.CHECKER'), prop: 'CHECKER', align: 'center' },
            { label: t('operate'), align: 'center', width: 100, render: 'buttons', buttons: optButtons, operator: false },
        ],
        dblClickNotEditColumn: [undefined, ],
        defaultOrder: { prop: 'TZID', order: 'desc' },
    },
    {
        defaultItems: [],
    }
)

provide('baTable', baTable)

onMounted(() => {
    baTable.table.ref = tableRef.value
    baTable.mount()
    baTable.getIndex()?.then(() => {
        baTable.initSort()
        baTable.dragSort()
    })
})
</script>

<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
    name: 'tz',
})
</script>

<style scoped lang="scss"></style>
